{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Execute this cell to install dependencies\n",
    "%pip install sf-hamilton[visualization]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "source": [
    "# Hello World Example [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dagworks-inc/hamilton/blob/main/examples/hello_world/my_notebook.ipynb) [![GitHub badge](https://img.shields.io/badge/github-view_source-2b3137?logo=github)](https://github.com/apache/hamilton/blob/main/examples/hello_world/my_notebook.ipynb)\n",
    "This uses the jupyter magic commands to create a simple example of how to use Hamilton."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-05T05:39:54.379474Z",
     "start_time": "2024-06-05T05:39:47.097691Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "# Cell 1 - import the things you need\n",
    "import logging\n",
    "import sys\n",
    "from hamilton import driver\n",
    "\n",
    "%load_ext hamilton.plugins.jupyter_magic\n",
    "logging.basicConfig(stream=sys.stdout)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-05T05:41:01.783934Z",
     "start_time": "2024-06-05T05:41:01.152301Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 10.0.1 (20240210.2158)\n",
       " -->\n",
       "<!-- Pages: 1 -->\n",
       "<svg width=\"731pt\" height=\"529pt\"\n",
       " viewBox=\"0.00 0.00 730.90 528.80\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 524.8)\">\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-524.8 726.9,-524.8 726.9,4 -4,4\"/>\n",
       "<g id=\"clust1\" class=\"cluster\">\n",
       "<title>cluster__legend</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" points=\"17.38,-382.8 17.38,-512.8 102.22,-512.8 102.22,-382.8 17.38,-382.8\"/>\n",
       "<text text-anchor=\"middle\" x=\"59.8\" y=\"-495.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Legend</text>\n",
       "</g>\n",
       "<!-- spend_std_dev -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>spend_std_dev</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M437.17,-63.6C437.17,-63.6 341.32,-63.6 341.32,-63.6 335.32,-63.6 329.32,-57.6 329.32,-51.6 329.32,-51.6 329.32,-12 329.32,-12 329.32,-6 335.32,0 341.32,0 341.32,0 437.17,0 437.17,0 443.17,0 449.17,-6 449.17,-12 449.17,-12 449.17,-51.6 449.17,-51.6 449.17,-57.6 443.17,-63.6 437.17,-63.6\"/>\n",
       "<text text-anchor=\"start\" x=\"340.12\" y=\"-40.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_std_dev</text>\n",
       "<text text-anchor=\"start\" x=\"376.5\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">float</text>\n",
       "</g>\n",
       "<!-- spend_zero_mean_unit_variance -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M710.9,-104.6C710.9,-104.6 500.3,-104.6 500.3,-104.6 494.3,-104.6 488.3,-98.6 488.3,-92.6 488.3,-92.6 488.3,-53 488.3,-53 488.3,-47 494.3,-41 500.3,-41 500.3,-41 710.9,-41 710.9,-41 716.9,-41 722.9,-47 722.9,-53 722.9,-53 722.9,-92.6 722.9,-92.6 722.9,-98.6 716.9,-104.6 710.9,-104.6\"/>\n",
       "<text text-anchor=\"start\" x=\"499.1\" y=\"-81.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_zero_mean_unit_variance</text>\n",
       "<text text-anchor=\"start\" x=\"586.47\" y=\"-53.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend_std_dev&#45;&gt;spend_zero_mean_unit_variance -->\n",
       "<g id=\"edge8\" class=\"edge\">\n",
       "<title>spend_std_dev&#45;&gt;spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M449.67,-43.17C458.31,-44.82 467.47,-46.57 476.85,-48.36\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"475.97,-51.76 486.45,-50.2 477.29,-44.88 475.97,-51.76\"/>\n",
       "</g>\n",
       "<!-- spend_zero_mean -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>spend_zero_mean</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M447.3,-145.6C447.3,-145.6 331.2,-145.6 331.2,-145.6 325.2,-145.6 319.2,-139.6 319.2,-133.6 319.2,-133.6 319.2,-94 319.2,-94 319.2,-88 325.2,-82 331.2,-82 331.2,-82 447.3,-82 447.3,-82 453.3,-82 459.3,-88 459.3,-94 459.3,-94 459.3,-133.6 459.3,-133.6 459.3,-139.6 453.3,-145.6 447.3,-145.6\"/>\n",
       "<text text-anchor=\"start\" x=\"330\" y=\"-122.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_zero_mean</text>\n",
       "<text text-anchor=\"start\" x=\"370.12\" y=\"-94.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend_zero_mean&#45;&gt;spend_zero_mean_unit_variance -->\n",
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>spend_zero_mean&#45;&gt;spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M459.55,-100.55C465.14,-99.48 470.89,-98.38 476.72,-97.26\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"477.37,-100.7 486.54,-95.38 476.06,-93.82 477.37,-100.7\"/>\n",
       "</g>\n",
       "<!-- avg_3wk_spend -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>avg_3wk_spend</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M270.32,-289.6C270.32,-289.6 168.47,-289.6 168.47,-289.6 162.47,-289.6 156.47,-283.6 156.47,-277.6 156.47,-277.6 156.47,-238 156.47,-238 156.47,-232 162.47,-226 168.47,-226 168.47,-226 270.32,-226 270.32,-226 276.32,-226 282.32,-232 282.32,-238 282.32,-238 282.32,-277.6 282.32,-277.6 282.32,-283.6 276.32,-289.6 270.32,-289.6\"/>\n",
       "<text text-anchor=\"start\" x=\"167.27\" y=\"-266.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">avg_3wk_spend</text>\n",
       "<text text-anchor=\"start\" x=\"200.27\" y=\"-238.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend_mean -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>spend_mean</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M259.82,-207.6C259.82,-207.6 178.97,-207.6 178.97,-207.6 172.97,-207.6 166.97,-201.6 166.97,-195.6 166.97,-195.6 166.97,-156 166.97,-156 166.97,-150 172.97,-144 178.97,-144 178.97,-144 259.82,-144 259.82,-144 265.82,-144 271.82,-150 271.82,-156 271.82,-156 271.82,-195.6 271.82,-195.6 271.82,-201.6 265.82,-207.6 259.82,-207.6\"/>\n",
       "<text text-anchor=\"start\" x=\"177.77\" y=\"-184.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_mean</text>\n",
       "<text text-anchor=\"start\" x=\"206.65\" y=\"-156.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">float</text>\n",
       "</g>\n",
       "<!-- spend_mean&#45;&gt;spend_zero_mean -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>spend_mean&#45;&gt;spend_zero_mean</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M272.13,-156.69C283.53,-152.48 295.86,-147.93 308.09,-143.41\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"309.19,-146.73 317.36,-139.99 306.76,-140.17 309.19,-146.73\"/>\n",
       "</g>\n",
       "<!-- spend_per_signup -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>spend_per_signup</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M278.2,-371.6C278.2,-371.6 160.6,-371.6 160.6,-371.6 154.6,-371.6 148.6,-365.6 148.6,-359.6 148.6,-359.6 148.6,-320 148.6,-320 148.6,-314 154.6,-308 160.6,-308 160.6,-308 278.2,-308 278.2,-308 284.2,-308 290.2,-314 290.2,-320 290.2,-320 290.2,-359.6 290.2,-359.6 290.2,-365.6 284.2,-371.6 278.2,-371.6\"/>\n",
       "<text text-anchor=\"start\" x=\"159.4\" y=\"-348.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_per_signup</text>\n",
       "<text text-anchor=\"start\" x=\"200.27\" y=\"-320.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- _spend_std_dev_inputs -->\n",
       "<g id=\"node7\" class=\"node\">\n",
       "<title>_spend_std_dev_inputs</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"274.7,-54.1 164.1,-54.1 164.1,-9.5 274.7,-9.5 274.7,-54.1\"/>\n",
       "<text text-anchor=\"start\" x=\"178.9\" y=\"-26\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">spend</text>\n",
       "<text text-anchor=\"start\" x=\"221.65\" y=\"-26\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- _spend_std_dev_inputs&#45;&gt;spend_std_dev -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>_spend_std_dev_inputs&#45;&gt;spend_std_dev</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M274.9,-31.8C288.57,-31.8 303.43,-31.8 317.76,-31.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"317.59,-35.3 327.59,-31.8 317.59,-28.3 317.59,-35.3\"/>\n",
       "</g>\n",
       "<!-- _spend_zero_mean_inputs -->\n",
       "<g id=\"node8\" class=\"node\">\n",
       "<title>_spend_zero_mean_inputs</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"274.7,-126.1 164.1,-126.1 164.1,-81.5 274.7,-81.5 274.7,-126.1\"/>\n",
       "<text text-anchor=\"start\" x=\"178.9\" y=\"-98\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">spend</text>\n",
       "<text text-anchor=\"start\" x=\"221.65\" y=\"-98\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- _spend_zero_mean_inputs&#45;&gt;spend_zero_mean -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>_spend_zero_mean_inputs&#45;&gt;spend_zero_mean</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M274.9,-107.05C285.27,-107.66 296.33,-108.32 307.32,-108.98\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"307.01,-112.47 317.21,-109.57 307.43,-105.48 307.01,-112.47\"/>\n",
       "</g>\n",
       "<!-- _avg_3wk_spend_inputs -->\n",
       "<g id=\"node9\" class=\"node\">\n",
       "<title>_avg_3wk_spend_inputs</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"115.1,-280.1 4.5,-280.1 4.5,-235.5 115.1,-235.5 115.1,-280.1\"/>\n",
       "<text text-anchor=\"start\" x=\"19.3\" y=\"-252\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">spend</text>\n",
       "<text text-anchor=\"start\" x=\"62.05\" y=\"-252\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- _avg_3wk_spend_inputs&#45;&gt;avg_3wk_spend -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>_avg_3wk_spend_inputs&#45;&gt;avg_3wk_spend</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M115.48,-257.8C124.87,-257.8 134.77,-257.8 144.57,-257.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"144.47,-261.3 154.47,-257.8 144.47,-254.3 144.47,-261.3\"/>\n",
       "</g>\n",
       "<!-- _spend_mean_inputs -->\n",
       "<g id=\"node10\" class=\"node\">\n",
       "<title>_spend_mean_inputs</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"115.1,-198.1 4.5,-198.1 4.5,-153.5 115.1,-153.5 115.1,-198.1\"/>\n",
       "<text text-anchor=\"start\" x=\"19.3\" y=\"-170\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">spend</text>\n",
       "<text text-anchor=\"start\" x=\"62.05\" y=\"-170\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- _spend_mean_inputs&#45;&gt;spend_mean -->\n",
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>_spend_mean_inputs&#45;&gt;spend_mean</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M115.48,-175.8C128.34,-175.8 142.14,-175.8 155.34,-175.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"155.22,-179.3 165.22,-175.8 155.22,-172.3 155.22,-179.3\"/>\n",
       "</g>\n",
       "<!-- _spend_per_signup_inputs -->\n",
       "<g id=\"node11\" class=\"node\">\n",
       "<title>_spend_per_signup_inputs</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"119.6,-372.6 0,-372.6 0,-307 119.6,-307 119.6,-372.6\"/>\n",
       "<text text-anchor=\"start\" x=\"19.42\" y=\"-344.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">spend</text>\n",
       "<text text-anchor=\"start\" x=\"66.67\" y=\"-344.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Series</text>\n",
       "<text text-anchor=\"start\" x=\"14.55\" y=\"-323.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">signups</text>\n",
       "<text text-anchor=\"start\" x=\"66.67\" y=\"-323.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- _spend_per_signup_inputs&#45;&gt;spend_per_signup -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>_spend_per_signup_inputs&#45;&gt;spend_per_signup</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M119.93,-339.8C125.57,-339.8 131.36,-339.8 137.16,-339.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"136.8,-343.3 146.8,-339.8 136.8,-336.3 136.8,-343.3\"/>\n",
       "</g>\n",
       "<!-- input -->\n",
       "<g id=\"node12\" class=\"node\">\n",
       "<title>input</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"86.8,-427.1 32.8,-427.1 32.8,-390.5 86.8,-390.5 86.8,-427.1\"/>\n",
       "<text text-anchor=\"middle\" x=\"59.8\" y=\"-403\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input</text>\n",
       "</g>\n",
       "<!-- function -->\n",
       "<g id=\"node13\" class=\"node\">\n",
       "<title>function</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M82.22,-482.1C82.22,-482.1 37.37,-482.1 37.37,-482.1 31.37,-482.1 25.37,-476.1 25.37,-470.1 25.37,-470.1 25.37,-457.5 25.37,-457.5 25.37,-451.5 31.37,-445.5 37.37,-445.5 37.37,-445.5 82.22,-445.5 82.22,-445.5 88.22,-445.5 94.22,-451.5 94.22,-457.5 94.22,-457.5 94.22,-470.1 94.22,-470.1 94.22,-476.1 88.22,-482.1 82.22,-482.1\"/>\n",
       "<text text-anchor=\"middle\" x=\"59.8\" y=\"-458\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">function</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x14c6006d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%cell_to_module my_functions --display\n",
    "# Cell 2 - Define your functions in a module.\n",
    "import pandas as pd\n",
    "\n",
    "def avg_3wk_spend(spend: pd.Series) -> pd.Series:\n",
    "    \"\"\"Rolling 3 week average spend.\"\"\"\n",
    "    return spend.rolling(3).mean()\n",
    "\n",
    "def spend_per_signup(spend: pd.Series, signups: pd.Series) -> pd.Series:\n",
    "    \"\"\"The cost per signup in relation to spend.\"\"\"\n",
    "    return spend / signups\n",
    "\n",
    "def spend_mean(spend: pd.Series) -> float:\n",
    "    \"\"\"Shows function creating a scalar. In this case it computes the mean of the entire column.\"\"\"\n",
    "    return spend.mean()\n",
    "\n",
    "def spend_zero_mean(spend: pd.Series, spend_mean: float) -> pd.Series:\n",
    "    \"\"\"Shows function that takes a scalar. In this case to zero mean spend.\"\"\"\n",
    "    return spend - spend_mean\n",
    "\n",
    "def spend_std_dev(spend: pd.Series) -> float:\n",
    "    \"\"\"Function that computes the standard deviation of the spend column.\"\"\"\n",
    "    return spend.std()\n",
    "\n",
    "def spend_zero_mean_unit_variance(spend_zero_mean: pd.Series, spend_std_dev: float) -> pd.Series:\n",
    "    \"\"\"Function showing one way to make spend have zero mean and unit variance.\"\"\"\n",
    "    return spend_zero_mean / spend_std_dev\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-11-08T00:06:17.404504Z",
     "start_time": "2023-11-08T00:06:17.343242Z"
    },
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# Cell 3 - Optional - if you have existing modules you can import them here.\n",
    "# We use the autoreload extension that comes with ipython to automatically reload modules when\n",
    "# the code in them changes.\n",
    "\n",
    "# import the jupyter extension\n",
    "%load_ext autoreload\n",
    "# set it to only reload the modules imported\n",
    "%autoreload 1\n",
    "# import the function modules you want to reload when they change.\n",
    "# i.e. these should be your modules you write your functions in. As you change them,\n",
    "# they will be reimported without you having to do anything.\n",
    "# %aimport NAME_OF_MODULE   # uncomment and replace NAME_OF_MODULE with the name of your module"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-05T05:43:08.346466Z",
     "start_time": "2024-06-05T05:43:07.937399Z"
    },
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 10.0.1 (20240210.2158)\n",
       " -->\n",
       "<!-- Pages: 1 -->\n",
       "<svg width=\"391pt\" height=\"364pt\"\n",
       " viewBox=\"0.00 0.00 391.20 363.80\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 359.8)\">\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-359.8 387.2,-359.8 387.2,4 -4,4\"/>\n",
       "<g id=\"clust1\" class=\"cluster\">\n",
       "<title>cluster__legend</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" points=\"50,-217.8 50,-347.8 134.85,-347.8 134.85,-217.8 50,-217.8\"/>\n",
       "<text text-anchor=\"middle\" x=\"92.43\" y=\"-330.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Legend</text>\n",
       "</g>\n",
       "<!-- spend -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>spend</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M111.1,-63.6C111.1,-63.6 73.75,-63.6 73.75,-63.6 67.75,-63.6 61.75,-57.6 61.75,-51.6 61.75,-51.6 61.75,-12 61.75,-12 61.75,-6 67.75,0 73.75,0 73.75,0 111.1,0 111.1,0 117.1,0 123.1,-6 123.1,-12 123.1,-12 123.1,-51.6 123.1,-51.6 123.1,-57.6 117.1,-63.6 111.1,-63.6\"/>\n",
       "<text text-anchor=\"start\" x=\"72.55\" y=\"-40.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend</text>\n",
       "<text text-anchor=\"start\" x=\"73.3\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- log_spend_per_signup -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>log_spend_per_signup</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M371.2,-135.6C371.2,-135.6 225.85,-135.6 225.85,-135.6 219.85,-135.6 213.85,-129.6 213.85,-123.6 213.85,-123.6 213.85,-84 213.85,-84 213.85,-78 219.85,-72 225.85,-72 225.85,-72 371.2,-72 371.2,-72 377.2,-72 383.2,-78 383.2,-84 383.2,-84 383.2,-123.6 383.2,-123.6 383.2,-129.6 377.2,-135.6 371.2,-135.6\"/>\n",
       "<text text-anchor=\"start\" x=\"224.65\" y=\"-112.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">log_spend_per_signup</text>\n",
       "<text text-anchor=\"start\" x=\"279.4\" y=\"-84.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- signups -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>signups</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M117.1,-207.6C117.1,-207.6 67.75,-207.6 67.75,-207.6 61.75,-207.6 55.75,-201.6 55.75,-195.6 55.75,-195.6 55.75,-156 55.75,-156 55.75,-150 61.75,-144 67.75,-144 67.75,-144 117.1,-144 117.1,-144 123.1,-144 129.1,-150 129.1,-156 129.1,-156 129.1,-195.6 129.1,-195.6 129.1,-201.6 123.1,-207.6 117.1,-207.6\"/>\n",
       "<text text-anchor=\"start\" x=\"66.55\" y=\"-184.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">signups</text>\n",
       "<text text-anchor=\"start\" x=\"73.3\" y=\"-156.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- _log_spend_per_signup_inputs -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>_log_spend_per_signup_inputs</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"184.85,-126.1 0,-126.1 0,-81.5 184.85,-81.5 184.85,-126.1\"/>\n",
       "<text text-anchor=\"start\" x=\"14.8\" y=\"-98\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">spend_per_signup</text>\n",
       "<text text-anchor=\"start\" x=\"131.8\" y=\"-98\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- _log_spend_per_signup_inputs&#45;&gt;log_spend_per_signup -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>_log_spend_per_signup_inputs&#45;&gt;log_spend_per_signup</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M185.32,-103.8C190.92,-103.8 196.55,-103.8 202.15,-103.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"202.09,-107.3 212.09,-103.8 202.09,-100.3 202.09,-107.3\"/>\n",
       "</g>\n",
       "<!-- input -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>input</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"119.43,-262.1 65.43,-262.1 65.43,-225.5 119.43,-225.5 119.43,-262.1\"/>\n",
       "<text text-anchor=\"middle\" x=\"92.43\" y=\"-238\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input</text>\n",
       "</g>\n",
       "<!-- function -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>function</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M114.85,-317.1C114.85,-317.1 70,-317.1 70,-317.1 64,-317.1 58,-311.1 58,-305.1 58,-305.1 58,-292.5 58,-292.5 58,-286.5 64,-280.5 70,-280.5 70,-280.5 114.85,-280.5 114.85,-280.5 120.85,-280.5 126.85,-286.5 126.85,-292.5 126.85,-292.5 126.85,-305.1 126.85,-305.1 126.85,-311.1 120.85,-317.1 114.85,-317.1\"/>\n",
       "<text text-anchor=\"middle\" x=\"92.43\" y=\"-293\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">function</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x14cca3fa0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%cell_to_module extra_functions --display\n",
    "# Cell 4 - Define your new Hamilton functions \n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "# Look at `my_functions` to see how these functions connect.\n",
    "def signups() -> pd.Series:\n",
    "    \"\"\"Returns sign up values\"\"\"\n",
    "    return pd.Series([1, 10, 50, 100, 200, 400])\n",
    "\n",
    "def spend() -> pd.Series:\n",
    "    \"\"\"Returns the spend values\"\"\"\n",
    "    return pd.Series([10, 10, 20, 40, 40, 50])\n",
    "\n",
    "def log_spend_per_signup(spend_per_signup: pd.Series) -> pd.Series:\n",
    "    \"\"\"Simple function taking the logarithm of spend over signups.\"\"\"\n",
    "    return np.log(spend_per_signup)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-05T05:43:42.229169Z",
     "start_time": "2024-06-05T05:43:42.210553Z"
    },
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# Cell 5 - Instantiate the Hamilton driver and pass it the right things in.\n",
    "initial_config = {}\n",
    "# my_functions and extra_functions are the modules we created in cells 2 and 4.\n",
    "dr = driver.Driver(initial_config, my_functions, extra_functions)  # can pass in multiple modules\n",
    "# we need to specify what we want in the final dataframe.\n",
    "output_columns = [\n",
    "    \"spend\",\n",
    "    \"signups\",\n",
    "    \"avg_3wk_spend\",\n",
    "    \"spend_per_signup\",\n",
    "    \"spend_zero_mean_unit_variance\",\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-05T05:43:52.023683Z",
     "start_time": "2024-06-05T05:43:51.626814Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 10.0.1 (20240210.2158)\n",
       " -->\n",
       "<!-- Pages: 1 -->\n",
       "<svg width=\"728pt\" height=\"449pt\"\n",
       " viewBox=\"0.00 0.00 727.65 448.80\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 444.8)\">\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-444.8 723.65,-444.8 723.65,4 -4,4\"/>\n",
       "<g id=\"clust1\" class=\"cluster\">\n",
       "<title>cluster__legend</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" points=\"8,-357.8 8,-432.8 92.85,-432.8 92.85,-357.8 8,-357.8\"/>\n",
       "<text text-anchor=\"middle\" x=\"50.42\" y=\"-415.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Legend</text>\n",
       "</g>\n",
       "<!-- signups -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>signups</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M75.1,-347.6C75.1,-347.6 25.75,-347.6 25.75,-347.6 19.75,-347.6 13.75,-341.6 13.75,-335.6 13.75,-335.6 13.75,-296 13.75,-296 13.75,-290 19.75,-284 25.75,-284 25.75,-284 75.1,-284 75.1,-284 81.1,-284 87.1,-290 87.1,-296 87.1,-296 87.1,-335.6 87.1,-335.6 87.1,-341.6 81.1,-347.6 75.1,-347.6\"/>\n",
       "<text text-anchor=\"start\" x=\"24.55\" y=\"-324.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">signups</text>\n",
       "<text text-anchor=\"start\" x=\"31.3\" y=\"-296.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend_per_signup -->\n",
       "<g id=\"node8\" class=\"node\">\n",
       "<title>spend_per_signup</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M245.7,-347.6C245.7,-347.6 128.1,-347.6 128.1,-347.6 122.1,-347.6 116.1,-341.6 116.1,-335.6 116.1,-335.6 116.1,-296 116.1,-296 116.1,-290 122.1,-284 128.1,-284 128.1,-284 245.7,-284 245.7,-284 251.7,-284 257.7,-290 257.7,-296 257.7,-296 257.7,-335.6 257.7,-335.6 257.7,-341.6 251.7,-347.6 245.7,-347.6\"/>\n",
       "<text text-anchor=\"start\" x=\"126.9\" y=\"-324.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_per_signup</text>\n",
       "<text text-anchor=\"start\" x=\"167.77\" y=\"-296.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- signups&#45;&gt;spend_per_signup -->\n",
       "<g id=\"edge8\" class=\"edge\">\n",
       "<title>signups&#45;&gt;spend_per_signup</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M87.46,-315.8C92.82,-315.8 98.52,-315.8 104.36,-315.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"104.23,-319.3 114.23,-315.8 104.23,-312.3 104.23,-319.3\"/>\n",
       "</g>\n",
       "<!-- spend_std_dev -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>spend_std_dev</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M234.82,-265.6C234.82,-265.6 138.97,-265.6 138.97,-265.6 132.97,-265.6 126.97,-259.6 126.97,-253.6 126.97,-253.6 126.97,-214 126.97,-214 126.97,-208 132.97,-202 138.97,-202 138.97,-202 234.82,-202 234.82,-202 240.82,-202 246.82,-208 246.82,-214 246.82,-214 246.82,-253.6 246.82,-253.6 246.82,-259.6 240.82,-265.6 234.82,-265.6\"/>\n",
       "<text text-anchor=\"start\" x=\"137.77\" y=\"-242.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_std_dev</text>\n",
       "<text text-anchor=\"start\" x=\"174.15\" y=\"-214.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">float</text>\n",
       "</g>\n",
       "<!-- spend_zero_mean_unit_variance -->\n",
       "<g id=\"node9\" class=\"node\">\n",
       "<title>spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M707.65,-235.6C707.65,-235.6 497.05,-235.6 497.05,-235.6 491.05,-235.6 485.05,-229.6 485.05,-223.6 485.05,-223.6 485.05,-184 485.05,-184 485.05,-178 491.05,-172 497.05,-172 497.05,-172 707.65,-172 707.65,-172 713.65,-172 719.65,-178 719.65,-184 719.65,-184 719.65,-223.6 719.65,-223.6 719.65,-229.6 713.65,-235.6 707.65,-235.6\"/>\n",
       "<text text-anchor=\"start\" x=\"495.85\" y=\"-212.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_zero_mean_unit_variance</text>\n",
       "<text text-anchor=\"start\" x=\"583.22\" y=\"-184.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend_std_dev&#45;&gt;spend_zero_mean_unit_variance -->\n",
       "<g id=\"edge10\" class=\"edge\">\n",
       "<title>spend_std_dev&#45;&gt;spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M247.28,-229.67C301.62,-225.88 384.25,-220.06 456.05,-214.8 461.74,-214.38 467.55,-213.95 473.42,-213.52\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"473.55,-217.02 483.26,-212.79 473.03,-210.04 473.55,-217.02\"/>\n",
       "</g>\n",
       "<!-- spend_zero_mean -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>spend_zero_mean</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M429.42,-205.6C429.42,-205.6 313.32,-205.6 313.32,-205.6 307.32,-205.6 301.32,-199.6 301.32,-193.6 301.32,-193.6 301.32,-154 301.32,-154 301.32,-148 307.32,-142 313.32,-142 313.32,-142 429.42,-142 429.42,-142 435.42,-142 441.42,-148 441.42,-154 441.42,-154 441.42,-193.6 441.42,-193.6 441.42,-199.6 435.42,-205.6 429.42,-205.6\"/>\n",
       "<text text-anchor=\"start\" x=\"312.12\" y=\"-182.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_zero_mean</text>\n",
       "<text text-anchor=\"start\" x=\"352.25\" y=\"-154.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend_zero_mean&#45;&gt;spend_zero_mean_unit_variance -->\n",
       "<g id=\"edge9\" class=\"edge\">\n",
       "<title>spend_zero_mean&#45;&gt;spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M441.7,-182.88C451.86,-184.21 462.58,-185.62 473.47,-187.05\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"472.99,-190.51 483.36,-188.34 473.9,-183.57 472.99,-190.51\"/>\n",
       "</g>\n",
       "<!-- log_spend_per_signup -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>log_spend_per_signup</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M444.05,-347.6C444.05,-347.6 298.7,-347.6 298.7,-347.6 292.7,-347.6 286.7,-341.6 286.7,-335.6 286.7,-335.6 286.7,-296 286.7,-296 286.7,-290 292.7,-284 298.7,-284 298.7,-284 444.05,-284 444.05,-284 450.05,-284 456.05,-290 456.05,-296 456.05,-296 456.05,-335.6 456.05,-335.6 456.05,-341.6 450.05,-347.6 444.05,-347.6\"/>\n",
       "<text text-anchor=\"start\" x=\"297.5\" y=\"-324.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">log_spend_per_signup</text>\n",
       "<text text-anchor=\"start\" x=\"352.25\" y=\"-296.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- avg_3wk_spend -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>avg_3wk_spend</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M237.82,-145.6C237.82,-145.6 135.97,-145.6 135.97,-145.6 129.97,-145.6 123.97,-139.6 123.97,-133.6 123.97,-133.6 123.97,-94 123.97,-94 123.97,-88 129.97,-82 135.97,-82 135.97,-82 237.82,-82 237.82,-82 243.82,-82 249.82,-88 249.82,-94 249.82,-94 249.82,-133.6 249.82,-133.6 249.82,-139.6 243.82,-145.6 237.82,-145.6\"/>\n",
       "<text text-anchor=\"start\" x=\"134.77\" y=\"-122.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">avg_3wk_spend</text>\n",
       "<text text-anchor=\"start\" x=\"167.77\" y=\"-94.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>spend</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M69.1,-205.6C69.1,-205.6 31.75,-205.6 31.75,-205.6 25.75,-205.6 19.75,-199.6 19.75,-193.6 19.75,-193.6 19.75,-154 19.75,-154 19.75,-148 25.75,-142 31.75,-142 31.75,-142 69.1,-142 69.1,-142 75.1,-142 81.1,-148 81.1,-154 81.1,-154 81.1,-193.6 81.1,-193.6 81.1,-199.6 75.1,-205.6 69.1,-205.6\"/>\n",
       "<text text-anchor=\"start\" x=\"30.55\" y=\"-182.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend</text>\n",
       "<text text-anchor=\"start\" x=\"31.3\" y=\"-154.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;spend_std_dev -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>spend&#45;&gt;spend_std_dev</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M81.27,-187.12C91.73,-191.78 103.96,-197.24 116.29,-202.74\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"114.7,-205.86 125.26,-206.74 117.55,-199.47 114.7,-205.86\"/>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;spend_zero_mean -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>spend&#45;&gt;spend_zero_mean</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M81.43,-173.8C128.56,-173.8 221.55,-173.8 289.35,-173.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"289.33,-177.3 299.33,-173.8 289.33,-170.3 289.33,-177.3\"/>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;avg_3wk_spend -->\n",
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>spend&#45;&gt;avg_3wk_spend</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M81.27,-160.48C90.87,-156.2 101.95,-151.25 113.25,-146.22\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"114.55,-149.47 122.26,-142.2 111.7,-143.07 114.55,-149.47\"/>\n",
       "</g>\n",
       "<!-- spend_mean -->\n",
       "<g id=\"node7\" class=\"node\">\n",
       "<title>spend_mean</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M227.32,-63.6C227.32,-63.6 146.47,-63.6 146.47,-63.6 140.47,-63.6 134.47,-57.6 134.47,-51.6 134.47,-51.6 134.47,-12 134.47,-12 134.47,-6 140.47,0 146.47,0 146.47,0 227.32,0 227.32,0 233.32,0 239.32,-6 239.32,-12 239.32,-12 239.32,-51.6 239.32,-51.6 239.32,-57.6 233.32,-63.6 227.32,-63.6\"/>\n",
       "<text text-anchor=\"start\" x=\"145.27\" y=\"-40.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_mean</text>\n",
       "<text text-anchor=\"start\" x=\"174.15\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">float</text>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;spend_mean -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>spend&#45;&gt;spend_mean</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M66.78,-141.9C78.22,-120.52 95.4,-92.72 116.1,-72.8 118.92,-70.09 121.95,-67.48 125.12,-64.98\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"127.08,-67.88 133.1,-59.16 122.96,-62.23 127.08,-67.88\"/>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;spend_per_signup -->\n",
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>spend&#45;&gt;spend_per_signup</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M66.78,-205.7C78.22,-227.08 95.4,-254.88 116.1,-274.8 116.71,-275.38 117.33,-275.96 117.95,-276.54\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"115.47,-279.02 125.38,-282.75 119.96,-273.65 115.47,-279.02\"/>\n",
       "</g>\n",
       "<!-- spend_mean&#45;&gt;spend_zero_mean -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>spend_mean&#45;&gt;spend_zero_mean</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M239.73,-60.67C245.91,-64.56 252.03,-68.65 257.7,-72.8 283.06,-91.32 309.3,-114.57 330.07,-134.09\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"327.57,-136.54 337.23,-140.88 332.38,-131.46 327.57,-136.54\"/>\n",
       "</g>\n",
       "<!-- spend_per_signup&#45;&gt;log_spend_per_signup -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>spend_per_signup&#45;&gt;log_spend_per_signup</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M258.19,-315.8C263.82,-315.8 269.56,-315.8 275.32,-315.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"274.89,-319.3 284.89,-315.8 274.89,-312.3 274.89,-319.3\"/>\n",
       "</g>\n",
       "<!-- function -->\n",
       "<g id=\"node10\" class=\"node\">\n",
       "<title>function</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M72.85,-402.1C72.85,-402.1 28,-402.1 28,-402.1 22,-402.1 16,-396.1 16,-390.1 16,-390.1 16,-377.5 16,-377.5 16,-371.5 22,-365.5 28,-365.5 28,-365.5 72.85,-365.5 72.85,-365.5 78.85,-365.5 84.85,-371.5 84.85,-377.5 84.85,-377.5 84.85,-390.1 84.85,-390.1 84.85,-396.1 78.85,-402.1 72.85,-402.1\"/>\n",
       "<text text-anchor=\"middle\" x=\"50.42\" y=\"-378\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">function</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x14cca3fa0>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Cell 5 - visualize execution\n",
    "# To visualize do `pip install \"sf-hamilton[visualization]\"` if you want these to work\n",
    "\n",
    "# visualize all possible functions\n",
    "dr.display_all_functions()  # no args needed for jupyter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-05T05:43:52.549992Z",
     "start_time": "2024-06-05T05:43:52.259829Z"
    },
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 10.0.1 (20240210.2158)\n",
       " -->\n",
       "<!-- Pages: 1 -->\n",
       "<svg width=\"698pt\" height=\"504pt\"\n",
       " viewBox=\"0.00 0.00 698.40 503.80\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 499.8)\">\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-499.8 694.4,-499.8 694.4,4 -4,4\"/>\n",
       "<g id=\"clust1\" class=\"cluster\">\n",
       "<title>cluster__legend</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" points=\"8,-357.8 8,-487.8 92.85,-487.8 92.85,-357.8 8,-357.8\"/>\n",
       "<text text-anchor=\"middle\" x=\"50.42\" y=\"-470.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Legend</text>\n",
       "</g>\n",
       "<!-- signups -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>signups</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M75.1,-347.6C75.1,-347.6 25.75,-347.6 25.75,-347.6 19.75,-347.6 13.75,-341.6 13.75,-335.6 13.75,-335.6 13.75,-296 13.75,-296 13.75,-290 19.75,-284 25.75,-284 25.75,-284 75.1,-284 75.1,-284 81.1,-284 87.1,-290 87.1,-296 87.1,-296 87.1,-335.6 87.1,-335.6 87.1,-341.6 81.1,-347.6 75.1,-347.6\"/>\n",
       "<text text-anchor=\"start\" x=\"24.55\" y=\"-324.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">signups</text>\n",
       "<text text-anchor=\"start\" x=\"31.3\" y=\"-296.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend_per_signup -->\n",
       "<g id=\"node7\" class=\"node\">\n",
       "<title>spend_per_signup</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M245.7,-347.6C245.7,-347.6 128.1,-347.6 128.1,-347.6 122.1,-347.6 116.1,-341.6 116.1,-335.6 116.1,-335.6 116.1,-296 116.1,-296 116.1,-290 122.1,-284 128.1,-284 128.1,-284 245.7,-284 245.7,-284 251.7,-284 257.7,-290 257.7,-296 257.7,-296 257.7,-335.6 257.7,-335.6 257.7,-341.6 251.7,-347.6 245.7,-347.6\"/>\n",
       "<text text-anchor=\"start\" x=\"126.9\" y=\"-324.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_per_signup</text>\n",
       "<text text-anchor=\"start\" x=\"167.77\" y=\"-296.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- signups&#45;&gt;spend_per_signup -->\n",
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>signups&#45;&gt;spend_per_signup</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M87.46,-315.8C92.82,-315.8 98.52,-315.8 104.36,-315.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"104.23,-319.3 114.23,-315.8 104.23,-312.3 104.23,-319.3\"/>\n",
       "</g>\n",
       "<!-- spend_std_dev -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>spend_std_dev</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M234.82,-265.6C234.82,-265.6 138.97,-265.6 138.97,-265.6 132.97,-265.6 126.97,-259.6 126.97,-253.6 126.97,-253.6 126.97,-214 126.97,-214 126.97,-208 132.97,-202 138.97,-202 138.97,-202 234.82,-202 234.82,-202 240.82,-202 246.82,-208 246.82,-214 246.82,-214 246.82,-253.6 246.82,-253.6 246.82,-259.6 240.82,-265.6 234.82,-265.6\"/>\n",
       "<text text-anchor=\"start\" x=\"137.77\" y=\"-242.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_std_dev</text>\n",
       "<text text-anchor=\"start\" x=\"174.15\" y=\"-214.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">float</text>\n",
       "</g>\n",
       "<!-- spend_zero_mean_unit_variance -->\n",
       "<g id=\"node8\" class=\"node\">\n",
       "<title>spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M678.4,-235.6C678.4,-235.6 467.8,-235.6 467.8,-235.6 461.8,-235.6 455.8,-229.6 455.8,-223.6 455.8,-223.6 455.8,-184 455.8,-184 455.8,-178 461.8,-172 467.8,-172 467.8,-172 678.4,-172 678.4,-172 684.4,-172 690.4,-178 690.4,-184 690.4,-184 690.4,-223.6 690.4,-223.6 690.4,-229.6 684.4,-235.6 678.4,-235.6\"/>\n",
       "<text text-anchor=\"start\" x=\"466.6\" y=\"-212.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_zero_mean_unit_variance</text>\n",
       "<text text-anchor=\"start\" x=\"553.97\" y=\"-184.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend_std_dev&#45;&gt;spend_zero_mean_unit_variance -->\n",
       "<g id=\"edge9\" class=\"edge\">\n",
       "<title>spend_std_dev&#45;&gt;spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M247.09,-229.18C299.42,-225.09 377.56,-218.99 444.11,-213.79\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"444.33,-217.29 454.03,-213.02 443.79,-210.31 444.33,-217.29\"/>\n",
       "</g>\n",
       "<!-- spend_zero_mean -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>spend_zero_mean</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M414.8,-205.6C414.8,-205.6 298.7,-205.6 298.7,-205.6 292.7,-205.6 286.7,-199.6 286.7,-193.6 286.7,-193.6 286.7,-154 286.7,-154 286.7,-148 292.7,-142 298.7,-142 298.7,-142 414.8,-142 414.8,-142 420.8,-142 426.8,-148 426.8,-154 426.8,-154 426.8,-193.6 426.8,-193.6 426.8,-199.6 420.8,-205.6 414.8,-205.6\"/>\n",
       "<text text-anchor=\"start\" x=\"297.5\" y=\"-182.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_zero_mean</text>\n",
       "<text text-anchor=\"start\" x=\"337.62\" y=\"-154.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend_zero_mean&#45;&gt;spend_zero_mean_unit_variance -->\n",
       "<g id=\"edge8\" class=\"edge\">\n",
       "<title>spend_zero_mean&#45;&gt;spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M427.05,-183.5C432.64,-184.28 438.39,-185.09 444.22,-185.9\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"443.63,-189.35 454.02,-187.27 444.6,-182.42 443.63,-189.35\"/>\n",
       "</g>\n",
       "<!-- spend -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>spend</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M69.1,-205.6C69.1,-205.6 31.75,-205.6 31.75,-205.6 25.75,-205.6 19.75,-199.6 19.75,-193.6 19.75,-193.6 19.75,-154 19.75,-154 19.75,-148 25.75,-142 31.75,-142 31.75,-142 69.1,-142 69.1,-142 75.1,-142 81.1,-148 81.1,-154 81.1,-154 81.1,-193.6 81.1,-193.6 81.1,-199.6 75.1,-205.6 69.1,-205.6\"/>\n",
       "<text text-anchor=\"start\" x=\"30.55\" y=\"-182.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend</text>\n",
       "<text text-anchor=\"start\" x=\"31.3\" y=\"-154.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;spend_std_dev -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>spend&#45;&gt;spend_std_dev</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M81.27,-187.12C91.73,-191.78 103.96,-197.24 116.29,-202.74\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"114.7,-205.86 125.26,-206.74 117.55,-199.47 114.7,-205.86\"/>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;spend_zero_mean -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>spend&#45;&gt;spend_zero_mean</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M81.44,-173.8C126.07,-173.8 211.51,-173.8 275.23,-173.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"274.94,-177.3 284.94,-173.8 274.94,-170.3 274.94,-177.3\"/>\n",
       "</g>\n",
       "<!-- avg_3wk_spend -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>avg_3wk_spend</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M237.82,-145.6C237.82,-145.6 135.97,-145.6 135.97,-145.6 129.97,-145.6 123.97,-139.6 123.97,-133.6 123.97,-133.6 123.97,-94 123.97,-94 123.97,-88 129.97,-82 135.97,-82 135.97,-82 237.82,-82 237.82,-82 243.82,-82 249.82,-88 249.82,-94 249.82,-94 249.82,-133.6 249.82,-133.6 249.82,-139.6 243.82,-145.6 237.82,-145.6\"/>\n",
       "<text text-anchor=\"start\" x=\"134.77\" y=\"-122.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">avg_3wk_spend</text>\n",
       "<text text-anchor=\"start\" x=\"167.77\" y=\"-94.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;avg_3wk_spend -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>spend&#45;&gt;avg_3wk_spend</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M81.27,-160.48C90.87,-156.2 101.95,-151.25 113.25,-146.22\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"114.55,-149.47 122.26,-142.2 111.7,-143.07 114.55,-149.47\"/>\n",
       "</g>\n",
       "<!-- spend_mean -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>spend_mean</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M227.32,-63.6C227.32,-63.6 146.47,-63.6 146.47,-63.6 140.47,-63.6 134.47,-57.6 134.47,-51.6 134.47,-51.6 134.47,-12 134.47,-12 134.47,-6 140.47,0 146.47,0 146.47,0 227.32,0 227.32,0 233.32,0 239.32,-6 239.32,-12 239.32,-12 239.32,-51.6 239.32,-51.6 239.32,-57.6 233.32,-63.6 227.32,-63.6\"/>\n",
       "<text text-anchor=\"start\" x=\"145.27\" y=\"-40.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_mean</text>\n",
       "<text text-anchor=\"start\" x=\"174.15\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">float</text>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;spend_mean -->\n",
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>spend&#45;&gt;spend_mean</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M66.78,-141.9C78.22,-120.52 95.4,-92.72 116.1,-72.8 118.92,-70.09 121.95,-67.48 125.12,-64.98\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"127.08,-67.88 133.1,-59.16 122.96,-62.23 127.08,-67.88\"/>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;spend_per_signup -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>spend&#45;&gt;spend_per_signup</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M66.78,-205.7C78.22,-227.08 95.4,-254.88 116.1,-274.8 116.71,-275.38 117.33,-275.96 117.95,-276.54\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"115.47,-279.02 125.38,-282.75 119.96,-273.65 115.47,-279.02\"/>\n",
       "</g>\n",
       "<!-- spend_mean&#45;&gt;spend_zero_mean -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>spend_mean&#45;&gt;spend_zero_mean</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M239.65,-60.05C245.9,-64.08 252.06,-68.37 257.7,-72.8 280.47,-90.68 303.16,-113.64 320.98,-133.15\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"318.24,-135.34 327.53,-140.43 323.44,-130.66 318.24,-135.34\"/>\n",
       "</g>\n",
       "<!-- function -->\n",
       "<g id=\"node9\" class=\"node\">\n",
       "<title>function</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M72.85,-402.1C72.85,-402.1 28,-402.1 28,-402.1 22,-402.1 16,-396.1 16,-390.1 16,-390.1 16,-377.5 16,-377.5 16,-371.5 22,-365.5 28,-365.5 28,-365.5 72.85,-365.5 72.85,-365.5 78.85,-365.5 84.85,-371.5 84.85,-377.5 84.85,-377.5 84.85,-390.1 84.85,-390.1 84.85,-396.1 78.85,-402.1 72.85,-402.1\"/>\n",
       "<text text-anchor=\"middle\" x=\"50.42\" y=\"-378\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">function</text>\n",
       "</g>\n",
       "<!-- output -->\n",
       "<g id=\"node10\" class=\"node\">\n",
       "<title>output</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M67.97,-457.1C67.97,-457.1 32.87,-457.1 32.87,-457.1 26.87,-457.1 20.87,-451.1 20.87,-445.1 20.87,-445.1 20.87,-432.5 20.87,-432.5 20.87,-426.5 26.87,-420.5 32.87,-420.5 32.87,-420.5 67.97,-420.5 67.97,-420.5 73.97,-420.5 79.97,-426.5 79.97,-432.5 79.97,-432.5 79.97,-445.1 79.97,-445.1 79.97,-451.1 73.97,-457.1 67.97,-457.1\"/>\n",
       "<text text-anchor=\"middle\" x=\"50.42\" y=\"-433\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">output</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x14cca3a90>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# visualize just the execution path\n",
    "dr.visualize_execution(output_columns)   # no other args needed for jupyter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-05T05:43:54.899373Z",
     "start_time": "2024-06-05T05:43:54.609411Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 10.0.1 (20240210.2158)\n",
       " -->\n",
       "<!-- Pages: 1 -->\n",
       "<svg width=\"674pt\" height=\"225pt\"\n",
       " viewBox=\"0.00 0.00 674.40 224.80\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 220.8)\">\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-220.8 670.4,-220.8 670.4,4 -4,4\"/>\n",
       "<g id=\"clust1\" class=\"cluster\">\n",
       "<title>cluster__legend</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" points=\"8,-133.8 8,-208.8 92.85,-208.8 92.85,-133.8 8,-133.8\"/>\n",
       "<text text-anchor=\"middle\" x=\"50.42\" y=\"-191.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Legend</text>\n",
       "</g>\n",
       "<!-- spend_std_dev -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>spend_std_dev</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M221.7,-183.6C221.7,-183.6 125.85,-183.6 125.85,-183.6 119.85,-183.6 113.85,-177.6 113.85,-171.6 113.85,-171.6 113.85,-132 113.85,-132 113.85,-126 119.85,-120 125.85,-120 125.85,-120 221.7,-120 221.7,-120 227.7,-120 233.7,-126 233.7,-132 233.7,-132 233.7,-171.6 233.7,-171.6 233.7,-177.6 227.7,-183.6 221.7,-183.6\"/>\n",
       "<text text-anchor=\"start\" x=\"124.65\" y=\"-160.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_std_dev</text>\n",
       "<text text-anchor=\"start\" x=\"161.02\" y=\"-132.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">float</text>\n",
       "</g>\n",
       "<!-- spend_zero_mean_unit_variance -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"red\" d=\"M654.4,-153.6C654.4,-153.6 443.8,-153.6 443.8,-153.6 437.8,-153.6 431.8,-147.6 431.8,-141.6 431.8,-141.6 431.8,-102 431.8,-102 431.8,-96 437.8,-90 443.8,-90 443.8,-90 654.4,-90 654.4,-90 660.4,-90 666.4,-96 666.4,-102 666.4,-102 666.4,-141.6 666.4,-141.6 666.4,-147.6 660.4,-153.6 654.4,-153.6\"/>\n",
       "<text text-anchor=\"start\" x=\"442.6\" y=\"-130.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_zero_mean_unit_variance</text>\n",
       "<text text-anchor=\"start\" x=\"529.97\" y=\"-102.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend_std_dev&#45;&gt;spend_zero_mean_unit_variance -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>spend_std_dev&#45;&gt;spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M233.93,-147.05C283.87,-143.03 357.14,-137.14 420.37,-132.06\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"420.44,-135.57 430.13,-131.28 419.88,-128.59 420.44,-135.57\"/>\n",
       "</g>\n",
       "<!-- spend_zero_mean -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>spend_zero_mean</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"red\" d=\"M390.8,-123.6C390.8,-123.6 274.7,-123.6 274.7,-123.6 268.7,-123.6 262.7,-117.6 262.7,-111.6 262.7,-111.6 262.7,-72 262.7,-72 262.7,-66 268.7,-60 274.7,-60 274.7,-60 390.8,-60 390.8,-60 396.8,-60 402.8,-66 402.8,-72 402.8,-72 402.8,-111.6 402.8,-111.6 402.8,-117.6 396.8,-123.6 390.8,-123.6\"/>\n",
       "<text text-anchor=\"start\" x=\"273.5\" y=\"-100.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_zero_mean</text>\n",
       "<text text-anchor=\"start\" x=\"313.62\" y=\"-72.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend_zero_mean&#45;&gt;spend_zero_mean_unit_variance -->\n",
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>spend_zero_mean&#45;&gt;spend_zero_mean_unit_variance</title>\n",
       "<path fill=\"none\" stroke=\"red\" d=\"M403.05,-101.5C408.64,-102.28 414.39,-103.09 420.22,-103.9\"/>\n",
       "<polygon fill=\"red\" stroke=\"red\" points=\"419.63,-107.35 430.02,-105.27 420.6,-100.42 419.63,-107.35\"/>\n",
       "</g>\n",
       "<!-- spend -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>spend</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M69.1,-123.6C69.1,-123.6 31.75,-123.6 31.75,-123.6 25.75,-123.6 19.75,-117.6 19.75,-111.6 19.75,-111.6 19.75,-72 19.75,-72 19.75,-66 25.75,-60 31.75,-60 31.75,-60 69.1,-60 69.1,-60 75.1,-60 81.1,-66 81.1,-72 81.1,-72 81.1,-111.6 81.1,-111.6 81.1,-117.6 75.1,-123.6 69.1,-123.6\"/>\n",
       "<text text-anchor=\"start\" x=\"30.55\" y=\"-100.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend</text>\n",
       "<text text-anchor=\"start\" x=\"31.3\" y=\"-72.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;spend_std_dev -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>spend&#45;&gt;spend_std_dev</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M81.42,-106.63C88.25,-110.01 95.79,-113.74 103.52,-117.56\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"101.87,-120.64 112.38,-121.94 104.97,-114.37 101.87,-120.64\"/>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;spend_zero_mean -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>spend&#45;&gt;spend_zero_mean</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M81.42,-91.8C121.53,-91.8 194.14,-91.8 250.87,-91.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"250.84,-95.3 260.84,-91.8 250.84,-88.3 250.84,-95.3\"/>\n",
       "</g>\n",
       "<!-- spend_mean -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>spend_mean</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"red\" d=\"M214.2,-63.6C214.2,-63.6 133.35,-63.6 133.35,-63.6 127.35,-63.6 121.35,-57.6 121.35,-51.6 121.35,-51.6 121.35,-12 121.35,-12 121.35,-6 127.35,0 133.35,0 133.35,0 214.2,0 214.2,0 220.2,0 226.2,-6 226.2,-12 226.2,-12 226.2,-51.6 226.2,-51.6 226.2,-57.6 220.2,-63.6 214.2,-63.6\"/>\n",
       "<text text-anchor=\"start\" x=\"132.15\" y=\"-40.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">spend_mean</text>\n",
       "<text text-anchor=\"start\" x=\"161.02\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">float</text>\n",
       "</g>\n",
       "<!-- spend&#45;&gt;spend_mean -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>spend&#45;&gt;spend_mean</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M81.42,-76.97C90.37,-72.54 100.53,-67.52 110.74,-62.47\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"112.15,-65.68 119.56,-58.11 109.05,-59.41 112.15,-65.68\"/>\n",
       "</g>\n",
       "<!-- spend_mean&#45;&gt;spend_zero_mean -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>spend_mean&#45;&gt;spend_zero_mean</title>\n",
       "<path fill=\"none\" stroke=\"red\" d=\"M226.61,-51.61C234.65,-54.68 243.11,-57.92 251.59,-61.16\"/>\n",
       "<polygon fill=\"red\" stroke=\"red\" points=\"250.32,-64.42 260.91,-64.72 252.82,-57.88 250.32,-64.42\"/>\n",
       "</g>\n",
       "<!-- function -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>function</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M72.85,-178.1C72.85,-178.1 28,-178.1 28,-178.1 22,-178.1 16,-172.1 16,-166.1 16,-166.1 16,-153.5 16,-153.5 16,-147.5 22,-141.5 28,-141.5 28,-141.5 72.85,-141.5 72.85,-141.5 78.85,-141.5 84.85,-147.5 84.85,-153.5 84.85,-153.5 84.85,-166.1 84.85,-166.1 84.85,-172.1 78.85,-178.1 72.85,-178.1\"/>\n",
       "<text text-anchor=\"middle\" x=\"50.42\" y=\"-154\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">function</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x14cca3c70>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# visualize the path of execution between two functions\n",
    "dr.visualize_path_between(\"spend_mean\", \"spend_zero_mean_unit_variance\",\n",
    "                          strict_path_visualization=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-05T05:43:57.619299Z",
     "start_time": "2024-06-05T05:43:57.580545Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>spend</th>\n",
       "      <th>signups</th>\n",
       "      <th>avg_3wk_spend</th>\n",
       "      <th>spend_per_signup</th>\n",
       "      <th>spend_zero_mean_unit_variance</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>10.000</td>\n",
       "      <td>-1.064405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000</td>\n",
       "      <td>-1.064405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>20</td>\n",
       "      <td>50</td>\n",
       "      <td>13.333333</td>\n",
       "      <td>0.400</td>\n",
       "      <td>-0.483821</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>40</td>\n",
       "      <td>100</td>\n",
       "      <td>23.333333</td>\n",
       "      <td>0.400</td>\n",
       "      <td>0.677349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>40</td>\n",
       "      <td>200</td>\n",
       "      <td>33.333333</td>\n",
       "      <td>0.200</td>\n",
       "      <td>0.677349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>50</td>\n",
       "      <td>400</td>\n",
       "      <td>43.333333</td>\n",
       "      <td>0.125</td>\n",
       "      <td>1.257934</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   spend  signups  avg_3wk_spend  spend_per_signup  \\\n",
       "0     10        1            NaN            10.000   \n",
       "1     10       10            NaN             1.000   \n",
       "2     20       50      13.333333             0.400   \n",
       "3     40      100      23.333333             0.400   \n",
       "4     40      200      33.333333             0.200   \n",
       "5     50      400      43.333333             0.125   \n",
       "\n",
       "   spend_zero_mean_unit_variance  \n",
       "0                      -1.064405  \n",
       "1                      -1.064405  \n",
       "2                      -0.483821  \n",
       "3                       0.677349  \n",
       "4                       0.677349  \n",
       "5                       1.257934  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# let's create the dataframe!\n",
    "dr.execute(output_columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-05-22T22:27:18.053784Z",
     "start_time": "2023-05-22T22:27:18.046215Z"
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
